﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LardonPokerSimulator.Model.Logging;
using System.Threading;
using System.Drawing;
using LardonPokerSimulator.Model.Observers;

namespace LardonPokerSimulator.Model
{
    public class Table : Subject
    {
        private static Table TABLE = new Table();

        private Player[] _players = null;

        private Table()
        {
            this._players = Player.GenerateRandomPlayers();

            /*foreach (Player p in this._players)
            {
               Log.AddLog(p.ToString());
            }*/

            //Log.Write(Console.Out);
        }

        public Player[] Players
        {
            get { return this._players; }
        }

        public void Draw(Graphics aGraphique)
        {
            SolidBrush greenTableBrush = new SolidBrush(Color.Green);
            Rectangle r = new Rectangle(100, 100, 600, 300);
            Pen pen = new Pen(Color.SaddleBrown, 5);
            pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;

            aGraphique.FillRectangle(greenTableBrush, r);
            aGraphique.DrawRectangle(pen, r);

            this._players.Select(x => {x.Draw(aGraphique);return x;}).ToList();

        }

        public static Table TableInstance
        {
            get { return TABLE; }
        }

        

    }
}
